{% macro make_structs(klass, is_public) -%}
  {% for _struct in klass.structs %}
    {% if is_public and _struct.public or
       not is_public and not _struct.public %}
    struct {{ _struct.name }}
    {
      {% for field in _struct.fields %}
        {{field.type}} {{field.name}}
          {% if "bits" in field %} : {{field.bits}}{% endif %}
          {% if "default" in field %} = {{field.default}}{% endif %};
          {% if "comment" in field %} {{field.comment}}{% endif %}
      {% endfor %}
    };
    {% endif %}
  {% endfor %}
{%- endmacro %}

{% macro make_enums(klass, is_public) -%}
  {% for _enum in klass.enums %}
    {% if is_public and _enum.public or
       not is_public and not _enum.public %}
    enum {% if _enum.class %} class {% endif %}
         {{ _enum.name }}
         {% if "type" in _enum %} : {{ _enum.type }}{% endif %}
    {
      {% for value in _enum["values"]%}
        {% if not loop.first %},{%endif%} {{value}}
      {% endfor %}
    };
    {% endif %}
  {% endfor %}
{%- endmacro %}

{% macro getter_signature(field, klass=None) -%}
  {% if klass %}{% set prefix = klass.name + "::" %}{% endif %}
  {% if field.dbSetGetter %}
    dbSet<{{field.type}}> {{prefix}}get{{field.functional_name}}() const
  {% elif field.isPassByRef %}
    void {{prefix}}{{field.getterFunctionName}}({{field.getterReturnType}}& tbl) const
  {% elif field.isHashTable %}
    {{field.getterReturnType}} {{prefix}}{{field.getterFunctionName}}(const char* name) const
  {% else %}
    {{field.getterReturnType}} {{prefix}}{{field.getterFunctionName}}() const
  {% endif %}
{%- endmacro %}

{% macro table_type(itr) -%}
  {% if itr.tablePageSize %}
     dbTable<_{{itr.parentObject}}, {{itr.tablePageSize}}>
  {% else %}
     dbTable<_{{itr.parentObject}}>
  {% endif %}
{%- endmacro %}
